package test.edu;

import com.edu.ActionContext;
import entity.Student;
import interceptor.Interceptor;
import interceptor.InterceptorChain;
import view.ForwardViewResult;
import view.RedirectViewResult;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class EHandler implements Interceptor{

    public void abc(String a,int b) throws ServletException, IOException {
        /*System.out.println("--"+a);
        System.out.println("--"+b);
        HttpServletRequest request = ActionContext.getContext().getRequest();
        HttpServletResponse response = ActionContext.getContext().getResponse();
        request.setAttribute("aa",a);
        request.getRequestDispatcher("/index1.jsp").forward(request,response);*/

        ActionContext.getContext().getRequest().setAttribute("aa",a);
        new ForwardViewResult("/index1.jsp").execute();
    }

    @Override
    public Object intercept(InterceptorChain chain) {
        System.out.println("拦截器Before1111111");
        Object handle = chain.handle();
        System.out.println("拦截器After11111");
        return handle;
    }
}
